package cn.bdqn.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigManager {
	//读取配置文件database.properties的工具类
	//读取配置文件用properties.load(inputStream)
	private  static ConfigManager configManager;
	private static Properties properties;
	//单例模式
	private ConfigManager(){
		String configFile = "jdbc.properties";
		properties = new Properties();
		InputStream is = ConfigManager.class.getClassLoader().getResourceAsStream(configFile);
		try {
			properties.load(is);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				is.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
	public  static ConfigManager getInstance(){
		if(configManager == null){
			configManager = new ConfigManager();
		}
		return configManager;
	}
	//解析配置文件
	public String getString(String key){
		return properties.getProperty(key);
	}

}
